<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="public/nav"} {include file="public/nav-2"}
    <!-- 分割 -->
    <div class="layui-container fly-marginTop">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="fly-panel fly-panel-user " pad20="">
                    <div class="layui-tab layui-tab-brief" lay-filter="user">
                        <ul class="layui-tab-title">
                            <li><a href="{:url('account/alterinfo')}">信息修改</a></li>
                            <li class="layui-this">密码修改</li>
                        </ul>
                        <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form layui-form-pane">
                                    <form method="post" action="" id="myform">
                                        <div class="layui-form-item">
                                            <label for="L_pass" class="layui-form-label">当前密码</label>
                                            <div class="layui-input-inline">
                                                <input type="password" id="password" name="password" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label for="L_pass" class="layui-form-label">新密码</label>
                                            <div class="layui-input-inline">
                                                <input type="password" id="password1" name="password1" autocomplete="off" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">密码长度为6~18位</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label for="L_pass" class="layui-form-label">重复密码</label>
                                            <div class="layui-input-inline">
                                                <input type="password" id="password2" name="password2" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <button class="layui-btn" lay-filter="submit" lay-submit>提交</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {include file="public/side-bar"}
        </div>
    </div>
    <!-- 分割 -->
    {include file="public/foot"}
</body>
<script>
layui.use(['form', 'jquery', 'layer'], function() {
    var form = layui.form;
    var $ = layui.jquery;
    var layer = layui.layer;
    // console.log(password);
    //监听提交 

    form.on('submit(submit)', function(data) {
        // console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
         if (data.field['password1'] != data.field['password2']) {
                layer.msg('两次密码输入不一致！');
                return false;
            }
            if(data.field['password1'].length<6||data.field['password1'].length>18) {
                layer.msg('密码长度为6~18位！');
                return false;
            }
        $.ajax({
            url: "{:url('account/JudgePassword')}",
            type: 'post',
            data: data.field,
            dataType: "JSON",
            success: function(res) {
                // console.log("res=" + res.password);
                if (res.result == true) {
                    // layer.msg('密码输入正确');  
                    layer.open({
                        title: '输入提示',
                        content: '密码修改成功!',
                        shadeClose: true,
                        time: 1200,
                        anim: 0
                    });
                    $(".layui-input").blur();
                } else {
                    $(".layui-input").blur();
                    layer.msg('当前密码输入错误');
                }
            },
            error: function() {
                layer.msg('页面进入后台失败');
            }
        });
        return false;
    });
});
</script>

</html>